package tech.aister.redis;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

/**
 * 本来用来演示: redis测试
 *
 * @author success
 * @date 2025/3/4 10:36:58
 */
@SpringBootTest
public class RedisTest {
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 插入一个字符串  key-value形式
     */
    @Test
    public void testAddStr(){
        //redisTemplate.opsForValue().set("username","蔡根花");
        redisTemplate.opsForValue().set("username","蔡根花",15, TimeUnit.SECONDS);
    }

    @Test
    public void testGetStr(){
        String username = (String) redisTemplate.opsForValue().get("username");
        System.out.println("username:"+username);
    }
}